package net.whg.pattern;

import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DeclaredAmountPattern {

    public static void main(String[] args) {
        String text = "4556431324513这个金额是123.56元哈哈哈";
        Pattern pattern = Pattern.compile("(\\d+(\\.\\d{1,2})?+元)");
        Matcher matcher = pattern.matcher(text);
        while (matcher.find()) {
            // 提取匹配的金额数字部分
            String amount = matcher.group(1).replace("元", "");
            System.out.println(amount);
        }
    }
}
